name=$1
version=$2
prefix=$3

if [ -z "$version" ]; then
  echo "ctr镜像转为docker镜像, 参数: 镜像名  版本"
  exit 1;
fi

if [ -z "$prefix" ]; then
  prefix="docker.io/library"
fi

rm  -rf tar-d-tmp.tar
ctr i export tar-d-tmp.tar  $prefix/$name:$version

docker load -i tar-d-tmp.tar
docker tag  $name:$version   amy:8082/tools/$name:$version
docker push amy:8082/tools/$name:$version

echo "完成镜像转换 $name:$version"